package ooday03.practise.practise_01;


public class AnimalTest {
    public static void main(String[] args) {
        Animal animal=new Dog("黑梓",4,"黑色");
        //System.out.println(animal.lookHome);  //多态,通过.访问,看引用的类型,父类中没有的方法不能访问
        System.out.println(animal.getName());   //访问父类普通方法(没被重写)
        System.out.println(animal.toString());  //访问父类普通方法,(被重写)去调用重写方法
        animal.eat();                           //访问父类抽象方法,去调用子类重写方法


        System.out.println("-----------------");
        Dog dog=new Dog("小黄",3,"棕色");
        dog.eat();
        dog.drink();
        dog.lookHome();
        dog.swim();
        System.out.println("----------------------");
        Chick chick=new Chick("鸡先锋",1,"花色");
        chick.eat();
        chick.drink();
        chick.layEggs();
        System.out.println("----------------------");
        Fish fish=new Fish("金龙鱼",2,"红色");
        fish.eat();
        fish.drink();
        fish.swim();

        Dog []dogs=new Dog[3];
        dogs[0]=new Dog("小黑",4,"黑色");
        dogs[1]=new Dog("小白",2,"白色");
        dogs[2]=new Dog("小灰",1,"灰色");

        for (Dog dog1:dogs){
            System.out.println(dog1.toString());
        }

        Fish []fishss=new Fish[3];
        fishss[0]=new Fish("小鲤鱼",4,"红色");
        fishss[1]=new Fish("乐乐",2,"金色");
        fishss[2]=new Fish("佩佩",1,"黑色色");

        for (Fish fish1:fishss){
            System.out.println(fish1.toString());
        }

        Chick []chicks=new Chick[2];
        chicks[0]=new Chick("鸡小龙",3,"黄色");
        chicks[1]=new Chick("鸡公煲",2,"棕色");

        for (Chick c:chicks){
            System.out.println(c.toString());
        }
    }
}
